package com.ruoyi.quartz.task;

import com.hhkj.admin.common.event.DailyZeroHourTimeUpEvent;
import com.hhkj.admin.common.event.EventPublisher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component("dailyZeroHourTask")
public class DailyZeroHourTask {

    @Autowired
    private EventPublisher eventPublisher;

    /**
     * 用监听器方法的名字来判断对应的监听器是否执行任务，多个任务用","隔开。
     * @param task
     */
    public void timeUp(String task)
    {
        String[] split = task.replace(" ", "").split(",");
        eventPublisher.sendEvent(new DailyZeroHourTimeUpEvent(Arrays.asList(split)));
    }
}
